$(document).ready(function(){
    $(".onsale").on('click',function(){
        if(confirm("确定要上架该商品吗？")){
            var goods_id = $(this).attr('data-id');
            $params = JSON.stringify({'goods_id':goods_id,'status':1});
            $offsale_back = ajaxSynchroRequest("/user/goodslist/set-status",$params);
            if($offsale_back.success==1){
                layer.msg('提交成功！'); 
                window.location.reload();
            }else{
                layer.msg($offsale_back.msg); 
            }
        }
    });
    $(".offsale").on('click',function(){
        if(confirm("确定要下架该商品吗？")){
            var goods_id = $(this).attr('data-id');
            $params = JSON.stringify({'goods_id':goods_id,'status':2});
            $offsale_back = ajaxSynchroRequest("/user/goodslist/set-status",$params);
            if($offsale_back.success==1){
                layer.msg('提交成功！'); 
                window.location.reload();
            }else{
                layer.msg($offsale_back.msg); 
            }
        }
    });
    $(".goods-delete").on('click',function(){
        if(confirm("确定要删除该商品吗？")){
            var goods_id = $(this).attr('data-id');
            $params = JSON.stringify({'goods_id':goods_id,'status':4});
            $offsale_back = ajaxSynchroRequest("/user/goodslist/set-status",$params);
            if($offsale_back.success==1){
                layer.msg('提交成功！');
                window.location.reload();
            }else{
                layer.msg($offsale_back.msg); 
            }
        }
        
    });
});
